package com.loren.demo33.controller;

import com.loren.demo33.event.BizEvent;
import com.loren.demo33.event.EventEngine;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private EventEngine eventEngine;

    @GetMapping("/doRegisterVip")
    public String doRegisterVip() {
        Map<String, Object> mapInfo = new HashMap<>(16);
        mapInfo.put("username", "Loren");
        mapInfo.put("age", 18);
        eventEngine.publishEvent(new BizEvent("111", UUID.randomUUID().toString(), mapInfo));
        eventEngine.publishEvent(new BizEvent("222", UUID.randomUUID().toString(), mapInfo));
        eventEngine.publishEvent(new BizEvent("333", UUID.randomUUID().toString(), mapInfo));
        return "success";
    }
}